Repository navigation
Add optional SonarCloud analysis to generated project template - #97
Merged
Merged
Conversation
Wires opt-in SonarCloud support into the templates/Source project template (GitHub Actions variants only). When a SONAR_TOKEN secret is configured, the Nuke build runs SonarScannerBegin/End around the existing build/test/coverage steps and the workflow sets up Java and passes the token through. Consumers who don't configure SONAR_TOKEN are unaffected (targets are skipped via OnlyWhenDynamic). - templates/Source/Build/Build.cs: add SonarToken/SonarOrganization/ SonarProjectKey/SonarHostUrl/UseSonarCloud, SonarBegin/SonarEnd targets, wire into Compile/Pack, feed ReportGenerator's SonarQube coverage format into the scanner. - templates/Source/.github/workflows/build.yml: setup-java + SONAR_TOKEN env var. - templates/Source/README.md: SonarCloud badge + opt-in setup note. - README.md: mention optional SonarCloud support. Closes #30 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Owner
Author
|
@copilot resolve the merge conflicts in this pull request |
…rcloud-support # Conflicts: # templates/Source/.github/workflows/build.yml Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
Contributor
Resolved in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #30
Adds opt-in SonarCloud analysis to the
templates/Source/...project template that this repo generates (GitHub Actions variants only — Azure DevOps variants are untouched since SonarCloud on ADO needs a different marketplace-extension-based setup and wasn't requested).What changed
templates/Source/Build/Build.cs: newSonarToken([Secret]),SonarHostUrlparameters, plusSonarOrganization/SonarProjectKey/UseSonarCloudcomputed from the GitHub Actions context (no newdotnet newsymbols needed). AddedSonarBegin/SonarEndNuke targets wired intoCompile/Pack, both gated withOnlyWhenDynamic(() => UseSonarCloud)so they're skipped entirely whenSonarTokenisn't set. Coverage is fed into Sonar via ReportGenerator's built-inSonarQubereport type (sonar.coverageReportPaths), so no extra Coverlet format juggling was needed.templates/Source/.github/workflows/build.yml: adds anactions/setup-java@v5step (JRE required bydotnet-sonarscanner), gated onsecrets.SONAR_TOKEN != '', and passesSonarToken: ${{ secrets.SONAR_TOKEN }}to the build step.templates/Source/README.md: SonarCloud badge (in the existing badge row) and a bullet explaining how to opt in (create a SonarCloud project, add aSONAR_TOKENsecret).README.md: mentions the new optional SonarCloud support in the feature list.Design
Non-breaking by default — a generated project that never sets up SonarCloud still gets a fully green build, mirroring the existing Coveralls no-op pattern.
Validation
Compile/Packtargets that Scriban-render all 6 template variants) — succeeded with no templating errors.NormalandNormalAzdovariants: SonarCloud code/YAML appears only in the GitHub Actions (non-azdo) variant; the Azdo variant has zero Sonar references.Normalvariant'sBuild.csdirectly withdotnet build— 0 errors, 0 warnings.